<!--
 * @Description: 
 * @Author: shizhe
 * @Date: 2021-10-29 16:58:22
 * @LastEditTime: 2022-07-04 10:10:50
 * @LastEditors: shizhe
 * @Reference: 
-->
<template>
  <div id="qutotation">
    <!-- <element-table
      ref="quota"
      :tableHeader="header"
      :interface="Interface"
      :isQuotation="true"
      @pagChange="getPagChange"
      @operateClick="operateClick"
    ></element-table> -->
    <el-table
      height="100%"
      :data="tableData"
      class="table"
      border
      ref="jdjgTable"
      tooltip-effect="light"
      @sort-change="sortChange"
      :header-cell-style="{
        padding: '0px',
        background: 'linear-gradient(0deg, #F4F6F9, #EAECF4, #F3F6F9)'
      }"
      :row-class-name="tabRowClassName"
      header-row-class-name="mapTable_th"
    >
      <el-table-column width="60" align="center" type="index" :index="addIndex" label="序号"> </el-table-column>
      <el-table-column label="供应商名称" align="center" width="338px" prop="bidEnterprise">
        <template slot-scope="scope">
          <el-button type="text" class="xg czBtn" size="small" @click="checkCompony(scope.row)">
            {{ scope.row.bidEnterprise }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="报价阶段" align="center" width="170px" prop="process"> </el-table-column>
      <el-table-column label="报价时间" align="center" width="200px" prop="createTime"> </el-table-column>
      <el-table-column label="报价总价(万元)" align="center" width="170px" prop="quoteNum"> </el-table-column>
      <el-table-column label="操作" align="center" width="180px">
        <template slot-scope="scope">
          <el-button type="text" class="xg czBtn" size="small" @click="operateClick('查看', scope.row)">
            查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <element-pagination @getData="getPagChange" :Total="total"></element-pagination>
    <el-dialog
      v-if="bidVisible"
      class="dialog_detail"
      :center="true"
      append-to-body
      :close-on-click-modal="false"
      width="1200px"
      title="查看投标书"
      lock-scroll
      :visible.sync="bidVisible"
    >
      <tender-fill :check="false" :Id="bidid" :bidId="bidId"></tender-fill>
    </el-dialog>
  </div>
</template>

<script>
import ElementPagination from '../../../../components/ElementPagination.vue'
import TenderFill from '../../../../components/TenderFill.vue'
// import ElementTable from '../../../../components/ElementTable.vue'
export default {
  props: {
    bidid: {
      type: Number,
      require: true
    }
  },
  components: { TenderFill, ElementPagination },
  data() {
    return {
      bidVisible: false,
      bidId: null,
      total: 0,
      tableData: [],
      page: 1,
      size: 15
      // Interface: {
      //   method: 'post',
      //   url: '/purchaseAdmin/enterpriseSelectedById',
      //   data: {
      //     biddingId: this.bidid,
      //     page: 1,
      //     size: 15,
      //     type: 3
      //   }
      // },
      // header: [
      //   { label: '供应商名称', prop: 'bidEnterprise', width: '338px' },
      //   { label: '报价阶段', prop: 'process', width: '170px' },
      //   { label: '报价时间', prop: 'createTime', width: '200px' },
      //   { label: '报价总价(万元)', prop: 'quoteNum', width: '170px' },
      //   { label: '操作', isBtn: true, prop: '', btnItem: [{ label: '查看' }], width: '180px' }
      // ]
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    checkCompony(row) {
      const { bidEnterpriseId } = row
      if (bidEnterpriseId) {
        localStorage.setItem('supplierID', bidEnterpriseId)
        const { href } = this.$router.resolve({ name: 'SupplierDetail', query: { id: bidEnterpriseId } })

        window.open(href, '_blank')
      }
    },
    operateClick(label, scope) {
      if (label === '查看') {
        this.bidId = scope.bidId
        this.bidVisible = true
      }
    },
    getPagChange(data) {
      this.page = data.currentPage
      this.size = data.pagesize
      this.getData()
    },
    getData() {
      this.$https({
        method: 'post',
        url: '/purchaseAdmin/enterpriseSelectedById',
        data: {
          page: this.page,
          size: this.size,
          type: 3,
          biddingId: this.bidid
        }
      }).then(res => {
        if (res.code == 0) {
          this.tableData = res.data.records || []
          this.total = res.data.total || 0
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    sortChange(e) {},
    addIndex(index) {
      return index + 1 + (this.page - 1) * this.size
    },
    tabRowClassName({ row, rowIndex }) {
      let index = rowIndex + 1
      if (index % 2 == 0) {
        return 'warning-row'
      }
    }
  }
}
</script>
<style lang="less" scoped></style>
